package com.example.materialcostsystembackend.model;

import com.fasterxml.jackson.annotation.JsonManagedReference;

import javax.persistence.*;
import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.util.List;

@Entity
@Table(name = "order_summary")
public class OrderSummary {
    @Id
    @Column(name = "order_number")
    private String orderNumber;

    private LocalDateTime exportTime;
    private BigDecimal totalQuantity;
    private BigDecimal totalCost;

    @OneToMany(mappedBy = "orderSummary", cascade = CascadeType.ALL, orphanRemoval = true)
    @JsonManagedReference   // 主控方
    private List<OrderItemDetail> items;

    public String getOrderNumber() { return orderNumber; }
    public void setOrderNumber(String orderNumber) { this.orderNumber = orderNumber; }
    public LocalDateTime getExportTime() { return exportTime; }
    public void setExportTime(LocalDateTime exportTime) { this.exportTime = exportTime; }
    public BigDecimal getTotalQuantity() { return totalQuantity; }
    public void setTotalQuantity(BigDecimal totalQuantity) { this.totalQuantity = totalQuantity; }
    public BigDecimal getTotalCost() { return totalCost; }
    public void setTotalCost(BigDecimal totalCost) { this.totalCost = totalCost; }
    public List<OrderItemDetail> getItems() { return items; }
    public void setItems(List<OrderItemDetail> items) { this.items = items; }
}